<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;

/**
 * @package App\Http\Controllers\Api
 * @see MessageController
 */
class MessageController extends BaseController
{

    /**
     * announce
     * @uri /message/announce
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request []
     * @response {"success":true,"statusCode":200,"result":{"total_count":4,"page":1,"page_size":20,"list":[{"id":1,"title":"\u7cfb\u7edf\u6d88\u606f\u6807\u9898","content":{"html":"\u516c\u544a\u5185\u5bb9","operating":"\u64cd\u4f5c"},"created_at":1597112552}]},"message":"OK"}
     */
    public function announce(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"total_count":4,"page":1,"page_size":20,"list":[{"id":1,"title":"\u7cfb\u7edf\u6d88\u606f\u6807\u9898","content":{"html":"\u516c\u544a\u5185\u5bb9","operating":"\u64cd\u4f5c"},"created_at":1597112552}]},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * clean
     * @uri /message/clean
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request []
     * @response {"success":true,"statusCode":200,"result":true,"message":"OK"}
     */
    public function clean(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":true,"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * commentReceive
     * @uri /message/comment-receive
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request []
     * @response {"success":true,"statusCode":200,"result":{"total_count":6,"page":1,"page_size":2,"list":[{"id":5,"created_at":1597198306,"main":{"id":"00KDNW0H4Q0USZ8I4PB60BV9","target_type":4,"content":"\u8fd9\u662f\u7b14\u8bb0\u7684\u8bc4\u8bba","user":{"id":"00K5H1KO60NAEIXXDT1SPMMM","nickname":"\u7c89\u5237\u5320","avatar":"ff56248a614b537781b7ff3cd4b3ad84.jpg"}},"child":{"id":"00KDNW6BWCYCHFITS38CXZGQ","content":"\u8fd9\u662f\u7b14\u8bb0\u7684\u56de\u590d","target_type":3,"user":{"id":"00K5HIY7S5QLRA0HE8DYIL0Y","nickname":"\u7267\u7f8a\u4eba\u5c0f\u96f7","avatar":"270871d1be5127f1e4a6040550c32bf7.png"}},"target":{"id":"00KDFJW207WS7X8HP8ZN04GM","content":"\u7b14\u8bb0\u5185\u5bb9","target_type":2,"article":{"id":"00KBZWSFY0JP7KPMYMJKX9STCKBZWSG0K","title":"\u5bf9\u4e0d\u8d77\uff0c\u516c\u53f8\u4e0d\u9700\u8981\u8fd9\u79cd\u201c\u9ad8\u60c5\u5546\u201d\u5458\u5de5","cover_url":"3f20d12d019d4ccc686b2f417ee10e46.jpg","description":"\u6587\u7ae0\u6458\u8981"}}},{"id":6,"created_at":1597198313,"main":{"id":"00KDNW0H4Q0USZ8I4PB60BV9","target_type":4,"content":"\u8fd9\u662f\u7b14\u8bb0\u7684\u8bc4\u8bba","user":{"id":"00K5H1KO60NAEIXXDT1SPMMM","nickname":"\u7c89\u5237\u5320","avatar":"ff56248a614b537781b7ff3cd4b3ad84.jpg"}},"child":{"id":"00KDNW6BWCYCHFITS38CXZGQ","content":"\u8fd9\u662f\u7b14\u8bb0\u56de\u590d\u7684\u56de\u590d","target_type":4,"user":{"id":"00K5L1KOTNVFQYGG6EZ0E13Z","nickname":"\u5f20\u5b97\u826f","avatar":"7bbd7428d04b0b8b52e1062a9cb990ba.png"}},"target":{"id":"00KDFJW207WS7X8HP8ZN04GM","target_type":2,"content":"\u7b14\u8bb0\u5185\u5bb9","article":{"id":"00KBZWSFY0JP7KPMYMJKX9STCKBZWSG0K","title":"\u5bf9\u4e0d\u8d77\uff0c\u516c\u53f8\u4e0d\u9700\u8981\u8fd9\u79cd\u201c\u9ad8\u60c5\u5546\u201d\u5458\u5de5","cover_url":"3f20d12d019d4ccc686b2f417ee10e46.jpg","description":"\u6587\u7ae0\u6458\u8981"}}}]},"message":"OK"}
     */
    public function commentReceive(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"total_count":6,"page":1,"page_size":2,"list":[{"id":5,"created_at":1597198306,"main":{"id":"00KDNW0H4Q0USZ8I4PB60BV9","target_type":4,"content":"\u8fd9\u662f\u7b14\u8bb0\u7684\u8bc4\u8bba","user":{"id":"00K5H1KO60NAEIXXDT1SPMMM","nickname":"\u7c89\u5237\u5320","avatar":"ff56248a614b537781b7ff3cd4b3ad84.jpg"}},"child":{"id":"00KDNW6BWCYCHFITS38CXZGQ","content":"\u8fd9\u662f\u7b14\u8bb0\u7684\u56de\u590d","target_type":3,"user":{"id":"00K5HIY7S5QLRA0HE8DYIL0Y","nickname":"\u7267\u7f8a\u4eba\u5c0f\u96f7","avatar":"270871d1be5127f1e4a6040550c32bf7.png"}},"target":{"id":"00KDFJW207WS7X8HP8ZN04GM","content":"\u7b14\u8bb0\u5185\u5bb9","target_type":2,"article":{"id":"00KBZWSFY0JP7KPMYMJKX9STCKBZWSG0K","title":"\u5bf9\u4e0d\u8d77\uff0c\u516c\u53f8\u4e0d\u9700\u8981\u8fd9\u79cd\u201c\u9ad8\u60c5\u5546\u201d\u5458\u5de5","cover_url":"3f20d12d019d4ccc686b2f417ee10e46.jpg","description":"\u6587\u7ae0\u6458\u8981"}}},{"id":6,"created_at":1597198313,"main":{"id":"00KDNW0H4Q0USZ8I4PB60BV9","target_type":4,"content":"\u8fd9\u662f\u7b14\u8bb0\u7684\u8bc4\u8bba","user":{"id":"00K5H1KO60NAEIXXDT1SPMMM","nickname":"\u7c89\u5237\u5320","avatar":"ff56248a614b537781b7ff3cd4b3ad84.jpg"}},"child":{"id":"00KDNW6BWCYCHFITS38CXZGQ","content":"\u8fd9\u662f\u7b14\u8bb0\u56de\u590d\u7684\u56de\u590d","target_type":4,"user":{"id":"00K5L1KOTNVFQYGG6EZ0E13Z","nickname":"\u5f20\u5b97\u826f","avatar":"7bbd7428d04b0b8b52e1062a9cb990ba.png"}},"target":{"id":"00KDFJW207WS7X8HP8ZN04GM","target_type":2,"content":"\u7b14\u8bb0\u5185\u5bb9","article":{"id":"00KBZWSFY0JP7KPMYMJKX9STCKBZWSG0K","title":"\u5bf9\u4e0d\u8d77\uff0c\u516c\u53f8\u4e0d\u9700\u8981\u8fd9\u79cd\u201c\u9ad8\u60c5\u5546\u201d\u5458\u5de5","cover_url":"3f20d12d019d4ccc686b2f417ee10e46.jpg","description":"\u6587\u7ae0\u6458\u8981"}}}]},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * commentSend
     * @uri /message/comment-send
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request []
     * @response {"success":true,"statusCode":200,"result":{"total_count":6,"page":1,"page_size":2,"list":[{"id":5,"created_at":1597198306,"main":{"id":"00KDNW0H4Q0USZ8I4PB60BV9","target_type":4,"content":"\u8fd9\u662f\u7b14\u8bb0\u7684\u8bc4\u8bba","user":{"id":"00K5H1KO60NAEIXXDT1SPMMM","nickname":"\u7c89\u5237\u5320","avatar":"ff56248a614b537781b7ff3cd4b3ad84.jpg"}},"child":{"id":"00KDNW6BWCYCHFITS38CXZGQ","content":"\u8fd9\u662f\u7b14\u8bb0\u7684\u56de\u590d","target_type":3,"user":{"id":"00K5HIY7S5QLRA0HE8DYIL0Y","nickname":"\u7267\u7f8a\u4eba\u5c0f\u96f7","avatar":"270871d1be5127f1e4a6040550c32bf7.png"}},"target":{"id":"00KDFJW207WS7X8HP8ZN04GM","content":"\u7b14\u8bb0\u5185\u5bb9","target_type":2,"article":{"id":"00KBZWSFY0JP7KPMYMJKX9STCKBZWSG0K","title":"\u5bf9\u4e0d\u8d77\uff0c\u516c\u53f8\u4e0d\u9700\u8981\u8fd9\u79cd\u201c\u9ad8\u60c5\u5546\u201d\u5458\u5de5","cover_url":"3f20d12d019d4ccc686b2f417ee10e46.jpg","description":"\u6587\u7ae0\u6458\u8981"}}},{"id":6,"created_at":1597198313,"main":{"id":"00KDNW0H4Q0USZ8I4PB60BV9","target_type":4,"content":"\u8fd9\u662f\u7b14\u8bb0\u7684\u8bc4\u8bba","user":{"id":"00K5H1KO60NAEIXXDT1SPMMM","nickname":"\u7c89\u5237\u5320","avatar":"ff56248a614b537781b7ff3cd4b3ad84.jpg"}},"child":{"id":"00KDNW6BWCYCHFITS38CXZGQ","content":"\u8fd9\u662f\u7b14\u8bb0\u56de\u590d\u7684\u56de\u590d","target_type":4,"user":{"id":"00K5L1KOTNVFQYGG6EZ0E13Z","nickname":"\u5f20\u5b97\u826f","avatar":"7bbd7428d04b0b8b52e1062a9cb990ba.png"}},"target":{"id":"00KDFJW207WS7X8HP8ZN04GM","target_type":2,"content":"\u7b14\u8bb0\u5185\u5bb9","article":{"id":"00KBZWSFY0JP7KPMYMJKX9STCKBZWSG0K","title":"\u5bf9\u4e0d\u8d77\uff0c\u516c\u53f8\u4e0d\u9700\u8981\u8fd9\u79cd\u201c\u9ad8\u60c5\u5546\u201d\u5458\u5de5","cover_url":"3f20d12d019d4ccc686b2f417ee10e46.jpg","description":"\u6587\u7ae0\u6458\u8981"}}}]},"message":"OK"}
     */
    public function commentSend(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"total_count":6,"page":1,"page_size":2,"list":[{"id":5,"created_at":1597198306,"main":{"id":"00KDNW0H4Q0USZ8I4PB60BV9","target_type":4,"content":"\u8fd9\u662f\u7b14\u8bb0\u7684\u8bc4\u8bba","user":{"id":"00K5H1KO60NAEIXXDT1SPMMM","nickname":"\u7c89\u5237\u5320","avatar":"ff56248a614b537781b7ff3cd4b3ad84.jpg"}},"child":{"id":"00KDNW6BWCYCHFITS38CXZGQ","content":"\u8fd9\u662f\u7b14\u8bb0\u7684\u56de\u590d","target_type":3,"user":{"id":"00K5HIY7S5QLRA0HE8DYIL0Y","nickname":"\u7267\u7f8a\u4eba\u5c0f\u96f7","avatar":"270871d1be5127f1e4a6040550c32bf7.png"}},"target":{"id":"00KDFJW207WS7X8HP8ZN04GM","content":"\u7b14\u8bb0\u5185\u5bb9","target_type":2,"article":{"id":"00KBZWSFY0JP7KPMYMJKX9STCKBZWSG0K","title":"\u5bf9\u4e0d\u8d77\uff0c\u516c\u53f8\u4e0d\u9700\u8981\u8fd9\u79cd\u201c\u9ad8\u60c5\u5546\u201d\u5458\u5de5","cover_url":"3f20d12d019d4ccc686b2f417ee10e46.jpg","description":"\u6587\u7ae0\u6458\u8981"}}},{"id":6,"created_at":1597198313,"main":{"id":"00KDNW0H4Q0USZ8I4PB60BV9","target_type":4,"content":"\u8fd9\u662f\u7b14\u8bb0\u7684\u8bc4\u8bba","user":{"id":"00K5H1KO60NAEIXXDT1SPMMM","nickname":"\u7c89\u5237\u5320","avatar":"ff56248a614b537781b7ff3cd4b3ad84.jpg"}},"child":{"id":"00KDNW6BWCYCHFITS38CXZGQ","content":"\u8fd9\u662f\u7b14\u8bb0\u56de\u590d\u7684\u56de\u590d","target_type":4,"user":{"id":"00K5L1KOTNVFQYGG6EZ0E13Z","nickname":"\u5f20\u5b97\u826f","avatar":"7bbd7428d04b0b8b52e1062a9cb990ba.png"}},"target":{"id":"00KDFJW207WS7X8HP8ZN04GM","target_type":2,"content":"\u7b14\u8bb0\u5185\u5bb9","article":{"id":"00KBZWSFY0JP7KPMYMJKX9STCKBZWSG0K","title":"\u5bf9\u4e0d\u8d77\uff0c\u516c\u53f8\u4e0d\u9700\u8981\u8fd9\u79cd\u201c\u9ad8\u60c5\u5546\u201d\u5458\u5de5","cover_url":"3f20d12d019d4ccc686b2f417ee10e46.jpg","description":"\u6587\u7ae0\u6458\u8981"}}}]},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * like
     * @uri /message/like
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request []
     * @response {"success":true,"statusCode":200,"result":{"total_count":6,"page":1,"page_size":2,"list":[{"id":382,"created_at":1605677998,"main":{"target_type":2},"child":{"id":"00KF3COB6DYZFZ0RV2R61Q23","target_type":2,"content":"\u7b14\u8bb0\u5185\u5bb9","is_fail":false,"article":{"id":"00KDBT47KI7EMIYZQAHZJN26","target_type":1,"cover_url":"5aec4dc84bb149aeb2b35bc7fd305571.jpg","title":"\u6587\u7ae0\u6807\u9898","description":"\u6587\u7ae0\u63cf\u8ff0","is_fail":false}}},{"id":383,"created_at":1605682371,"main":{"target_type":5},"child":{"id":"00KHLTTFBZ5PJZHRCRWXUFBD","target_type":1,"cover_url":"d7f52258c213e5cdd1adee1172662aa4.jpg","title":"\u6587\u7ae0\u6807\u9898","description":"\u6587\u7ae0\u63cf\u8ff0","is_fail":false}}]},"message":"OK"}
     */
    public function like(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"total_count":6,"page":1,"page_size":2,"list":[{"id":382,"created_at":1605677998,"main":{"target_type":2},"child":{"id":"00KF3COB6DYZFZ0RV2R61Q23","target_type":2,"content":"\u7b14\u8bb0\u5185\u5bb9","is_fail":false,"article":{"id":"00KDBT47KI7EMIYZQAHZJN26","target_type":1,"cover_url":"5aec4dc84bb149aeb2b35bc7fd305571.jpg","title":"\u6587\u7ae0\u6807\u9898","description":"\u6587\u7ae0\u63cf\u8ff0","is_fail":false}}},{"id":383,"created_at":1605682371,"main":{"target_type":5},"child":{"id":"00KHLTTFBZ5PJZHRCRWXUFBD","target_type":1,"cover_url":"d7f52258c213e5cdd1adee1172662aa4.jpg","title":"\u6587\u7ae0\u6807\u9898","description":"\u6587\u7ae0\u63cf\u8ff0","is_fail":false}}]},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * unread
     * @uri /message/unread
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request []
     * @response {"success":true,"statusCode":200,"result":{"comment":8,"like":99,"announce":109},"message":"OK"}
     */
    public function unread(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"comment":8,"like":99,"announce":109},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

}